package com.sou.technologytool.fragment;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.benben.commoncore.utils.StatusBarUtils;
import com.sou.technologytool.MyApplication;
import com.sou.technologytool.R;
import com.sou.technologytool.ui.PolicyActivity;
import com.sou.technologytool.ui.login.LoginActivity;

import java.util.Objects;

import butterknife.BindView;
import butterknife.OnClick;

public class MineFragment extends LazyBaseFragments{
    @BindView(R.id.bt_exit)
    TextView bt_exit;
    @BindView(R.id.tv_user_name)
    TextView tv_user_name;
    @BindView(R.id.tv_policy)
    TextView tv_policy;
    @BindView(R.id.status_bar_view)
    View statusBarView;

    private int mStatusBarHeight;

    @Override
    public View bindLayout(LayoutInflater inflater) {
        mRootView = inflater.inflate(R.layout.frag_mine, null);
        return mRootView;
    }

    @Override
    public void initView() {
        mStatusBarHeight = StatusBarUtils.getStatusBarHeight(mContext);
        statusBarView.getLayoutParams().height = mStatusBarHeight;
        tv_user_name.setText("+91 "+  MyApplication.mPreferenceProvider.getUserName());
    }

    @Override
    public void initData() {

    }

    @OnClick({R.id.bt_exit,R.id.tv_policy})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.bt_exit:
                MyApplication.mPreferenceProvider.setIsLogin(false);
                Intent intent = new Intent(mContext, LoginActivity.class);
                startActivity(intent);
                Objects.requireNonNull(getActivity()).finish();
                break;
            case R.id.tv_policy:
                Intent intentPolicy = new Intent(mContext, PolicyActivity.class);
                intentPolicy.putExtra("level", "https://sites.google.com/view/xxprivacy/");
                startActivity(intentPolicy);
                break;
        }
    }
}
